package com.yztstudy.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * 用户实体类
 */


@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "user")
public class User implements Serializable {

    public static final Long serialVersionUID = 1L;

    @TableId(value = "user_id", type = IdType.AUTO)
    @JsonProperty("user_id") // json的属性名变换，接收和发送的时候为user_id
    private Integer userId; // 用户主键

    @TableField(value = "user_name")
    @Length(min = 6)
    private String userName; //用户名

    @TableField(value = "PASSWORD")
    @NotBlank
    @JsonInclude(JsonInclude.Include.NON_NULL) // 为null时，不生成json，不为null时，生成json
    private String password; // 密码

    @TableField(value = "user_phonenumber")
    @NotBlank
    @JsonInclude(JsonInclude.Include.NON_NULL) // 为null时，不生成json，不为null时，生成json
    private String userPhoneNumber; //手机号

}
